Repository navigation
Conversation
…words KylinIdentifierPreparer's class body assigned directly to sqlalchemy.sql.compiler.IdentifierPreparer.reserved_words (the base class) instead of its own subclass attribute. Since this runs at class-definition/import time, merely importing kylinpy.sqla_dialect (e.g. via SQLAlchemy's dialect registry enumerating installed entry points) replaced the shared default every other SQLAlchemy dialect without its own reserved_words falls back on, for the rest of the process. Ordinary identifiers like "name" became globally "reserved" and started getting quoted in unrelated dialects' output. Fix: assign to KylinIdentifierPreparer's own reserved_words instead, the same pattern SQLAlchemy's built-in dialects use. Kylin's own reserved-word set (CALCITE_KEYWORDS + SUPERSET_KEYWORDS) is unchanged; only the leakage into the shared base class is removed. Verified with a regression test (subprocess-isolated, since the corruption persists for the rest of any process that already imported the old code) that fails red against the previous version and passes green here, plus a full run of the rest of the test suite that doesn't require a live Kylin server. Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KylinIdentifierPreparer's class body mutatessqlalchemy.sql.compiler.IdentifierPreparer.reserved_wordsdirectly:That's the base class's attribute, not
KylinIdentifierPreparer's own. Since this executes at class-definition/import time, just importingkylinpy.sqla_dialect(e.g. via SQLAlchemy's dialect entry-point registry enumerating installed dialects, which doesn't require actually connecting to Kylin) replaces the shared default that every other SQLAlchemy dialect without its ownreserved_wordsfalls back on, for the rest of the process. Ordinary identifiers likenamebecome globally "reserved" and start getting unexpectedly quoted in unrelated dialects' generated SQL.Reproduced directly:
We (Apache Superset) hit this in production: loading
kylinpy's dialect alongside other database dialects in the same process caused unrelated databases' queries to start quoting ordinary column names. We worked around it on our side (snapshotting/restoring the shared attribute around dialect loading), but the real fix belongs here.Fix
Assign to
KylinIdentifierPreparer's ownreserved_wordsinstead of the base class's, matching the pattern SQLAlchemy's built-in dialects (postgresql, mysql, etc.) use for exactly this reason. Kylin's own effective reserved-word set is unchanged -- sameCALCITE_KEYWORDS/SUPERSET_KEYWORDSunion, same values -- only the cross-dialect leakage into the shared base class is removed.Testing
Added
tests/test_reserved_words.py:compiler.IdentifierPreparer.reserved_wordsis unchanged after importingkylinpy.sqla_dialect.KylinIdentifierPreparer.reserved_wordsstill has Kylin's own full keyword set.Both fail red against the current code on
masterand pass green with this fix. Also ran the rest of the suite that doesn't require a live Kylin sandbox (test_compat,test_cube_source,test_kylin_types,test_kylinpy,test_sqla_types,test_table_source-- 26 tests) and confirmed no regressions.Note on repo activity
I noticed this repo hasn't had a commit since early 2023. I'm filing this anyway since it's a real, narrow, low-risk correctness bug with a minimal fix and clear reproduction -- happy to help in any way if there's interest in picking it back up, and no worries if not.
🤖 Generated with Claude Code